package ${packagePrefix}.common.exception;

<#if generateComments>
/**
 * 错误码枚举
 * <p>系统统一错误码定义，使用六位字符串，前两位代表模块，中间两位代表子模块，后两位代表具体错误</p>
 * <p>模块编号：</p>
 * <ul>
 *   <li>10: 系统通用</li>
 *   <li>20: 用户认证</li>
 *   <li>30: 权限模块</li>
 *   <li>40: ${domainObjectName}模块</li>
 *   <li>50-99: 其他业务模块</li>
 * </ul>
 *
 * @author Auto Generated
 */
</#if>
public enum ErrorCode {

    // ========== 系统通用 ==========
    SUCCESS("000000", "操作成功"),
    SYSTEM_ERROR("100000", "系统内部错误"),
    PARAM_ERROR("100001", "参数错误"),
    BUSINESS_ERROR("100002", "业务异常"),
    DUPLICATE_SUBMISSION("100003", "重复提交"),
    API_NOT_FOUND("100004", "接口不存在"),
    METHOD_NOT_ALLOWED("100005", "请求方法不允许"),
    MEDIA_TYPE_NOT_SUPPORTED("100006", "媒体类型不支持"),
    VALIDATION_ERROR("100007", "参数校验失败"),
    TOO_MANY_REQUESTS("100008", "请求过于频繁"),
    THIRD_PARTY_ERROR("100009", "第三方服务异常"),
    
    // ========== 用户认证 ==========
    UNAUTHORIZED("200001", "未授权"),
    LOGIN_ERROR("200002", "用户名或密码错误"),
    TOKEN_EXPIRED("200003", "登录凭证已过期"),
    TOKEN_INVALID("200004", "无效的登录凭证"),
    ACCOUNT_DISABLED("200005", "账号已被禁用"),
    ACCOUNT_LOCKED("200006", "账号已被锁定"),
    MULTI_LOGIN("200007", "账号已在其他设备登录"),
    PERMISSION_DENIED("200008", "权限不足"),
    
    // ========== ${domainObjectName}模块 ==========
    ${domainObjectName?upper_case}_NOT_FOUND("400001", "${domainObjectName}不存在"),
    ${domainObjectName?upper_case}_ALREADY_EXISTS("400002", "${domainObjectName}已存在"),
    ${domainObjectName?upper_case}_STATUS_ERROR("400003", "${domainObjectName}状态异常"),
    ${domainObjectName?upper_case}_DATA_INVALID("400004", "${domainObjectName}数据无效"),
<#if specialRequirements?? && specialRequirements?contains("审批")>
    ${domainObjectName?upper_case}_APPROVAL_STATUS_ERROR("400005", "${domainObjectName}审批状态异常"),
    ${domainObjectName?upper_case}_APPROVAL_REQUIRED("400006", "${domainObjectName}需要审批"),
</#if>
<#if specialRequirements?? && specialRequirements?contains("可删除")>
    ${domainObjectName?upper_case}_CANNOT_DELETE("400007", "${domainObjectName}不可删除"),
</#if>
<#if specialRequirements?? && specialRequirements?contains("使用中")>
    ${domainObjectName?upper_case}_IN_USE("400008", "${domainObjectName}已被使用"),
</#if>
    ${domainObjectName?upper_case}_OPERATION_NOT_ALLOWED("400009", "${domainObjectName}操作不允许");
    
    /**
     * 错误码
     */
    private final String code;
    
    /**
     * 错误消息
     */
    private final String message;
    
    ErrorCode(String code, String message) {
        this.code = code;
        this.message = message;
    }
    
    /**
     * 获取错误码
     *
     * @return 错误码
     */
    public String getCode() {
        return code;
    }
    
    /**
     * 获取错误消息
     *
     * @return 错误消息
     */
    public String getMessage() {
        return message;
    }
} 